<?php
/**
 * checker.php
 * Script to check if exists new images according to 
 * a given 'user' and 'last update' params. It returns
 * the new images info in JSON format
 *
 * $Id: checker.php 13 2007-08-08 06:03:41Z jonathan.hernandez $
 */
require_once "config/config.php";
require_once "include/FooModel.php";

// GET params
$username      = $_GET['username']; 
$last_update   = $_GET['last_update'];
$with_friends  = ($_GET['with_friends'] == 'with_friends');
try {
    $fv = new FooModel($conf);
    if ($json = $fv->getNodeImages($username, $last_update, $with_friends)) {
        header("Pragma: no-cache");
        header("Cache-Control: no-store, no-cache, max-age=0, must-revalidate");
        header('Content-Disposition: attachment; filename="'.$username.'.json"'); 
        header('Content-Type: text/x-json');
        header("X-JSON: ".$json);
        echo($json);
    } else {
        header('HTTP/1.0 400 Bad Request');
    }
} catch (Exception $e) {
    header('HTTP/1.0 500 Internal Server Error');
}
